package com.cqcvc.service;

import com.cqcvc.mapper.UserMapper;
import com.cqcvc.pojo.User;
import com.cqcvc.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapper userMapper;

    /**
     * 用户注册
     * @param zh
     * @param mm
     * @param name
     * @return
     */
    public int register(String zh,String mm,String name){
        return userMapper.register(zh, StringUtil.md5(mm), name);
    }

    /**
     * 校验账号的唯一性
     * @param zh
     * @return
     */
    public List<User> checkUserAccount(String zh){
        return userMapper.checkUserAccount(zh);
    }

    /**
     * 用户登录
     * @param zh
     * @param mm
     * @return
     */
    public User login(String zh,String mm){
        return userMapper.login(zh, StringUtil.md5(mm));
    }

    /**
     * 修改密码
     * @param zh
     * @param mm
     * @param newmm
     * @return
     */
    public int editPwd(String zh,String mm,String newmm){
        return userMapper.editPwd(zh, StringUtil.md5(mm), StringUtil.md5(newmm));
    }
}
